/*
 * A Gneral purpose java based Genome Library created by Susanta Tewari.
 * Copyright is protected. Contact Susanta Tewari at <statsusant@yahoo.com>
 */

package main.genomemap;

import javautil.io.IOUtil;
import javautil.lang.StringUtil;

import org.apache.ecs.html.A;
import org.apache.ecs.html.BR;
import org.apache.ecs.html.Body;
import org.apache.ecs.html.H2;
import org.apache.ecs.html.Head;
import org.apache.ecs.html.Html;
import org.apache.ecs.html.LI;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Susanta Tewari <stewari@yahoo.com>
 */
public class GenomeMapWeb {

    /** Field description */
    private static final String rootDirPath = "c:/repo/code/java_projects/GenomeMap/resources/web";

    /** Field description */
    private static final String pathSeparator = "/";

    public static void main(String[] args) {
        createWeb();
    }

    /**
     * create the integrated gene maps
     * @param ch_id
     */
    private static void createWeb() {

        String htmlPath = rootDirPath + pathSeparator + "imaps.html";
        Html html       = new Html();

        html.setPrettyPrint(true);
        html.addElement(new Head("GenomeMapWeb"));

        Body body = new Body();


        // integrated genetic maps
        body.addElement(new H2("Integrated Genetic Maps"));

        for (int i = 0; i < 7; i++) {

            body.addElement(new LI(new A("images" + pathSeparator + "igmaps" + pathSeparator
                                         + "IGeneMap_" + (i + 1) + ".jpg", "Chromosome "
                                             + StringUtil.getRoman(i + 1))));
        }


        // integrated probe maps
        body.addElement(new H2("Integrated Probe Maps"));

        for (int i = 0; i < 7; i++) {

            body.addElement(new LI(new A("images" + pathSeparator + "ipmaps" + pathSeparator
                                         + "IProbeMap_" + (i + 1) + ".jpg", "Chromosome "
                                             + StringUtil.getRoman(i + 1))));
        }


        // repeated DNA distribution map
        body.addElement(new BR());
        body.addElement(new BR());
        body.addElement(new A("images" + pathSeparator + "RepDNADistMap_Joint.jpg",
                              "Repeated DNA Distribution Map"));


        // full maps
        body.addElement(new H2("Full Hybridization Maps"));

        for (int i = 0; i < 7; i++) {

            body.addElement(new LI(new A("fullMaps" + pathSeparator + "fullMap_" + (i + 1)
                                         + ".txt", "Chromosome " + StringUtil.getRoman(i + 1))));
        }


        // compressed maps
        body.addElement(new H2("Compressed Hybridization Maps"));

        for (int i = 0; i < 7; i++) {

            body.addElement(new LI(new A("compressedMaps" + pathSeparator + "compressedMap_"
                                         + (i + 1) + ".txt", "Chromosome "
                                             + StringUtil.getRoman(i + 1))));
        }


        // add links to the raw data on
        body.addElement(new H2("Raw Data Used"));
        body.addElement(new LI(new A("rawdata" + pathSeparator + "CLONE_START_END_RAW.txt",
                                     "Clone Data Used")));
        body.addElement(new LI(new A("rawdata" + pathSeparator + "NCU_START_END_RAW.txt",
                                     "NCU Data Used")));
        html.addElement(body);


//      System.out.println(html.toString());
        try {
            IOUtil.writeToFile(new File(htmlPath), html.toString());
        } catch (IOException ex) {
            Logger.getLogger(GenomeMapWeb.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
